--[[/**
-- * 
蕾拉将自己普攻伤害的[0]%转化为生命值治疗生命值最低的友军
-- *
-- */]]

---@class BuffEffect53100 : BaseBuffEffect
BuffEffect53100 = ClientFight.CreateClass("BuffEffect53100", ClientFight.BaseBuffEffect)
local t = BuffEffect53100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
   local  parameters = {...};
    local fightResult = parameters[3];
    local fighter = buff.target;
    local effectVal = buff.buffBean.f_BuffEffectValue;
    if (fightResult.damage <= 0) then
     return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

    end
    local target = SkillManager.selectAttackTarget(fight, fighter, buff.skill.skill,
    SkillTargetRangeEnum.ALL, SkillTargetTypeEnum.FRIEND, SkillTargetRuleEnum.WEAKEST,
    0, nil, fighter.position, nil,
    nil, false);

    if (target == nil) then
        return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    end

    local addHp =  (fightResult.damage * Utils.toRatio(effectVal[1]));

    local curePer = FighterAttributeManager.getFightAttr(fighter, FighterAttributeEnum.CURE_PER);
    addHp = (addHp * Utils.toRatio(curePer));

    DamageManager.setFighterHp(fight, target, fighter, nil,
    DamageResultTypeEnum.HEAL, addHp, target.hp + addHp, true, false, true);

    BuffManager.addBuff(fight, buff.skill, fighter, target, false, effectVal[2], 1);
    local logAddHp = addHp;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s Buff%s 伤害为%s,转化增加生命值%s,目标为%s",
    fight.frame, fighter.fighterId, buff.modelId, fightResult.damage, logAddHp, target.fighterId
    ));

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()